p <- 10
first_n <- 150
corpula_mean_first <- c(10, 0, 10, 0, 10,
0, 10, 0, 10, 0) # mu
cov_mat_first <- matrix(0, p, p);
diag(cov_mat_first) <- c(20, 5, 20, 5, 20,
5, 20, 5, 20, 5)
norm_first <- MASS::mvrnorm(first_n, corpula_mean_first, cov_mat_first)
corpula_first <- norm_first
# nonparanormal transform
corpula_first <- apply(corpula_first, 2, function(x) {0.4 * sign(x) * abs(x)^1.6})
# this is the gaussian data we need to make nonparanormals
pairs(norm_first, asp = T, pch = 16, col = rgb(0.5,0.5,0.5,0.5), lower.panel = NULL)
# this is the nonparanormal
pairs(corpula_first, asp = T, pch = 16, col = rgb(0.5,0.5,0.5,0.5), lower.panel = NULL)
second_n <- 200
corpula_mean_second <- c(0, 10, 0, 10, 0,
10, 0, 10, 0, 10) # mu
cov_mat_second <- matrix(0, p, p)
diag(cov_mat_second) <- c(5, 20, 5, 20, 5,
20, 5, 20, 5, 20) # Sigma
norm_second <- MASS::mvrnorm(second_n, corpula_mean_second, cov_mat_second)
corpula_second <- norm_second
# nonparanormal transform
corpula_second <- apply(corpula_second, 2, function(x) {0.4 * sign(x) * abs(x)^1.6})
# this is the gaussian data we need to make nonparanormals
pairs(norm_second, asp = T, pch = 16, col = rgb(0.5,0.5,0.5,0.5), lower.panel = NULL)
# this is the nonparanormal
pairs(corpula_second, asp = T, pch = 16, col = rgb(0.5,0.5,0.5,0.5), lower.panel = NULL)
third_n <- 150
corpula_mean_third <- c(10, 0, 0, 10, 10,
8, 8, 10, 10, 8)
cov_mat_third <- matrix(4, p, p);
diag(cov_mat_third) <- c(5, 10, 5, 10, 5, 10, 5, 10, 5, 10) # Sigma
norm_third <- MASS::mvrnorm(third_n, corpula_mean_third, cov_mat_third)
corpula_third <- norm_third
# nonparanormal transform
corpula_third <- apply(corpula_third, 2, function(x) {0.6 * sign(x) * abs(x)^1.4})
norm_expr <- MASS::mvrnorm(third_n, corpula_mean_third, cov_mat_third)
# this is the gaussian data we need to make nonparanormals
pairs(norm_third, asp = T, pch = 16, col = rgb(0.5,0.5,0.5,0.5), lower.panel = NULL)
# this is the nonparanormal
pairs(corpula_third, asp = T, pch = 16, col = rgb(0.5,0.5,0.5,0.5), lower.panel = NULL)
full_dat <- rbind(cbind(corpula_first, rep(1, first_n)),
cbind(corpula_second, rep(2, second_n)),
cbind(corpula_third, rep(3, third_n)))
gen_dat <- full_dat[, 1:10]
gen_label <- full_dat[, 11]
pairs(gen_dat, asp = T, pch = 16, col = gen_label, lower.panel = NULL)
pairs(gen_dat, asp = T, pch = 16, col = rgb(0.5, 0.5, 0.5, 0.5), lower.panel = NULL)
library(reshape2) # melt function
library(ggplot2) # ggplot function
library(pcaPP) # Fast Kendall function
library(energy) # Distance Correlation
library(Hmisc) # Hoeffding's D measure
## Loading required package: lattice
## Loading required package: survival
## Loading required package: Formula
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
library(entropy) # Mutual Information
library(minerva) # Maximum Information Coefficient
library(XICOR) # Chatterjee's Coefficient
library(dHSIC) # Hilbert Schmidt Independence Criterion
library(VineCopula) # Blomqvist's Beta
make_cormat <- function(dat_mat){
matrix_dat <- matrix(nrow = ncol(dat_mat), ncol = ncol(dat_mat))
cor_mat_list <- list()
basic_cor <- c("pearson", "spearman")
# find each of the correlation matrices with Pearson, Spearman, Kendall Correlation Coefficients
for (i in 1:2){
cor_mat <- stats::cor(dat_mat, method = basic_cor[i])
cor_mat[upper.tri(cor_mat, diag = T)] <- NA
cor_mat_list[[i]] <- cor_mat
}
# functions that take matrix or data.frame as input
no_loop_function <- c(pcaPP::cor.fk, Hmisc::hoeffd,
minerva::mine, VineCopula::BetaMatrix)
for (i in 3:6){
fun <- no_loop_function[[i-2]]
cor_mat <- fun(dat_mat)
if (i == 4){ # Hoeffding's D
cor_mat <- cor_mat$D
} else if (i == 5){ # MIC
cor_mat <- cor_mat$MIC
}
cor_mat[upper.tri(cor_mat, diag = T)] <- NA
cor_mat_list[[i]] <- cor_mat
}
# functions that take two variables as input to calculate correlations.
need_loop <- c(energy::dcor2d, entropy::discretize2d,
XICOR::calculateXI, dHSIC::dhsic)
for (i in 7:10){
fun <- need_loop[[i-6]]
cor_mat <- matrix(nrow = ncol(dat_mat),
ncol = ncol(dat_mat))
for (j in 2:ncol(dat_mat)){
for (k in 1:(j-1)){
if (i == 8){ # Mutual Information
cor_mat[j, k] <- mi.empirical(fun(as.matrix(dat_mat[, j]),
as.matrix(dat_mat[, k]),
numBins1 = 20,
numBins2 = 20))
} else if (i == 10){ # HSIC
cor_mat[j, k] <- fun(as.numeric(dat_mat[, j]),
as.numeric(dat_mat[, k]))$dHSIC
} else {
cor_mat[j, k] <- fun(as.numeric(dat_mat[, j]),
as.numeric(dat_mat[, k]))
}
}
}
cor_mat[upper.tri(cor_mat, diag = T)] <- NA
cor_mat_list[[i]] <- cor_mat
}
return(cor_mat_list)
}
draw_heatmap <- function(cor_mat){
len <- 8
melted_cormat <- melt(cor_mat)
melted_cormat <- melted_cormat[!is.na(melted_cormat$value),]
break_vec <- round(as.numeric(quantile(melted_cormat$value,
probs = seq(0, 1, length.out = len),
na.rm = T)),
3)
break_vec[1] <- break_vec[1]-1
break_vec[len] <- break_vec[len]+1
melted_cormat$value <- cut(melted_cormat$value, breaks = break_vec)
heatmap_color <- unique(melted_cormat$value)
heatmap <- ggplot(data = melted_cormat, aes(x = Var2, y = Var1, fill = value))+
geom_tile(colour = "Black") +
ggplot2::scale_fill_manual(breaks = sort(heatmap_color),
values = rev(scales::viridis_pal(begin = 0, end = 1)
(length(heatmap_color)))) +
theme_bw() + # make the background white
theme(panel.border = element_blank(), panel.grid.major = element_blank(),
panel.grid.minor = element_blank(), axis.ticks = element_blank(),
# erase tick marks and labels
axis.text.x = element_blank(), axis.text.y = element_blank())
return (heatmap)
}
make_cor_heatmap <- function(dat_mat){
fun_lable <- c("Pearson's Correlation", "Spearman's Correlation", "Kendall's Correlation",
"Hoeffding's D", "MIC", "Blomqvist's Beta", "Distance Correlation",
"Mutual Information", "XI Correlation", "HSIC")
cor_heatmap_list <- list()
cor_abs_heatmap_list <- list()
# make correlation matrices
cor_mat_list <- make_cormat(dat_mat)
for (i in 1:10){
cor_mat <- cor_mat_list[[i]]
# get heatmaps
cor_heatmap <- draw_heatmap(cor_mat)
# ggplot labels
ggplot_labs <- labs(title = paste("Heatmap of", fun_lable[i]),
x = "",
y = "",
fill = "Coefficient") # change the title and legend label
cor_heatmap_list[[i]] <- cor_heatmap + ggplot_labs
if (i %in% c(1,2,3,4,6)){
cor_abs_mat <- abs(cor_mat_list[[i]])
cor_abs_heatmap <- draw_heatmap(cor_abs_mat)
ggplot_abs_labs <- labs(title = paste("Abs Heatmap of", fun_lable[i]),
x = "", # change the title and legend label
y = "",
fill = "Coefficient")
cor_abs_heatmap_list[[i]] <- cor_abs_heatmap + ggplot_abs_labs
} else {
ggplot_abs_labs <- labs(title = paste("Abs Heatmap of", fun_lable[i]),
subtitle = "Equivalent to Non-Abs Heatmap",
x = "", # change the title and legend label
y = "",
fill = "Coefficient")
cor_abs_heatmap_list[[i]] <- cor_heatmap + ggplot_abs_labs
}
}
ans <- list(cor_heatmap_list, cor_abs_heatmap_list)
return (ans)
}
lst <- make_cor_heatmap(gen_dat)
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
cormat_list <- make_cormat(gen_dat)
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
## Warning in KL.plugin(freqs2d, freqs.null, unit = unit): Vanishing value(s) in
## argument freqs2!
# lst[[1]]
lst[[1]][[4]]
cor_pearson_mat <- cormat_list[[1]]; cor_spearman_mat <- cormat_list[[2]];
cor_kendall_mat <- cormat_list[[3]]; cor_hoeffd_mat <- cormat_list[[4]];
cor_MIC_mat <- cormat_list[[5]]; cor_blomqvist_mat <- cormat_list[[6]];
cor_dist_mat <- cormat_list[[7]]; cor_MI_mat <- cormat_list[[8]];
cor_XI_mat <- cormat_list[[9]]; cor_HSIC_mat <- cormat_list[[10]];
cor_contrast1 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_spearman_mat) > 0.5)
cor_contrast_ind1 <- which(cor_contrast1, arr.ind = T)
nrow(cor_contrast_ind1)
## [1] 8
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind1)){
index1 <- cor_contrast_ind1[i, 1]; index2 <- cor_contrast_ind1[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Spearman of ", round(cor_spearman_mat[index1, index2], 3))))
}
cor_contrast2 <- (abs(cor_pearson_mat) > 0.5) & (abs(cor_spearman_mat) < 0.5)
cor_contrast_ind2 <- which(cor_contrast2, arr.ind = T)
nrow(cor_contrast_ind2)
## [1] 0
cor_contrast3 <- (abs(cor_pearson_mat) > 0.5) & (abs(cor_dist_mat) < 0.5)
cor_contrast_ind3 <- which(cor_contrast3, arr.ind = T)
nrow(cor_contrast_ind3)
## [1] 8
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind3)){
index1 <- cor_contrast_ind3[i, 1]; index2 <- cor_contrast_ind3[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Dist.Cor of ", round(cor_dist_mat[index1, index2], 3))))
}
cor_contrast4 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_dist_mat) > 0.5)
cor_contrast_ind4 <- which(cor_contrast4, arr.ind = T)
nrow(cor_contrast_ind4)
## [1] 0
cor_contrast5 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_MIC_mat) > 0.5)
cor_contrast_ind5 <- which(cor_contrast5, arr.ind = T)
nrow(cor_contrast_ind5)
## [1] 5
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind5)){
index1 <- cor_contrast_ind5[i, 1]; index2 <- cor_contrast_ind5[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("MIC of ", round(cor_MIC_mat[index1, index2], 3))))
}
cor_contrast6 <- (abs(cor_pearson_mat) > 0.5) & (abs(cor_MIC_mat) < 0.5)
cor_contrast_ind6 <- which(cor_contrast6, arr.ind = T)
nrow(cor_contrast_ind6)
## [1] 0
cor_contrast7 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind7 <- which(cor_contrast7, arr.ind = T)
nrow(cor_contrast_ind7)
## [1] 0
cor_contrast8 <- (abs(cor_pearson_mat) > 0.5) & (abs(cor_XI_mat) < 0.5)
cor_contrast_ind8 <- which(cor_contrast8, arr.ind = T)
nrow(cor_contrast_ind8)
## [1] 14
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind8)){
index1 <- cor_contrast_ind8[i, 1]; index2 <- cor_contrast_ind8[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}
cor_contrast9 <- (abs(cor_pearson_mat) < 0.5) & (abs(cor_blomqvist_mat) > 0.5)
cor_contrast_ind9 <- which(cor_contrast9, arr.ind = T)
nrow(cor_contrast_ind9)
## [1] 3
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind9)){
index1 <- cor_contrast_ind9[i, 1]; index2 <- cor_contrast_ind9[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}
cor_contrast10 <- (abs(cor_pearson_mat) > 0.5) & (abs(cor_blomqvist_mat) < 0.5)
cor_contrast_ind10 <- which(cor_contrast10, arr.ind = T)
nrow(cor_contrast_ind10)
## [1] 5
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind10)){
index1 <- cor_contrast_ind10[i, 1]; index2 <- cor_contrast_ind10[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Pearson of ", round(cor_pearson_mat[index1, index2], 3)),
"\n",
paste0("Beta of ", round(cor_blomqvist_mat[index1, index2], 3))))
}
cor_contrast11 <- (abs(cor_kendall_mat) < 0.5) & (abs(cor_dist_mat) > 0.5)
cor_contrast_ind11 <- which(cor_contrast11, arr.ind = T)
nrow(cor_contrast_ind11)
## [1] 0
cor_contrast12 <- (abs(cor_kendall_mat) > 0.5) & (abs(cor_dist_mat) < 0.5)
cor_contrast_ind12 <- which(cor_contrast12, arr.ind = T)
nrow(cor_contrast_ind12)
## [1] 0
cor_contrast13 <- (abs(cor_kendall_mat) < 0.5) & (abs(cor_MI_mat) > 0.5)
cor_contrast_ind13 <- which(cor_contrast13, arr.ind = T)
nrow(cor_contrast_ind13)
## [1] 10
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind13)){
index1 <- cor_contrast_ind13[i, 1]; index2 <- cor_contrast_ind13[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3)),
"\n",
paste0("MI of ", round(cor_MI_mat[index1, index2], 3))))
}
cor_contrast14 <- (abs(cor_kendall_mat) > 0.5) & (abs(cor_MI_mat) < 0.5)
cor_contrast_ind14 <- which(cor_contrast14, arr.ind = T)
nrow(cor_contrast_ind14)
## [1] 0
cor_contrast15 <- (abs(cor_kendall_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind15 <- which(cor_contrast15, arr.ind = T)
nrow(cor_contrast_ind15)
## [1] 0
cor_contrast16 <- (abs(cor_kendall_mat) > 0.5) & (abs(cor_XI_mat) < 0.5)
cor_contrast_ind16 <- which(cor_contrast16, arr.ind = T)
nrow(cor_contrast_ind16)
## [1] 6
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind16)){
index1 <- cor_contrast_ind16[i, 1]; index2 <- cor_contrast_ind16[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Kendall of ", round(cor_kendall_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}
cor_contrast17 <- (abs(cor_dist_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind17 <- which(cor_contrast17, arr.ind = T)
nrow(cor_contrast_ind17)
## [1] 0
cor_contrast18 <- (abs(cor_dist_mat) > 0.5) & (abs(cor_XI_mat) < 0.5)
cor_contrast_ind18 <- which(cor_contrast18, arr.ind = T)
nrow(cor_contrast_ind18)
## [1] 6
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind18)){
index1 <- cor_contrast_ind18[i, 1]; index2 <- cor_contrast_ind18[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Dist.Cor of ", round(cor_dist_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}
cor_contrast19 <- (abs(cor_blomqvist_mat) < 0.5) & (abs(cor_XI_mat) > 0.5)
cor_contrast_ind19 <- which(cor_contrast19, arr.ind = T)
nrow(cor_contrast_ind19)
## [1] 0
cor_contrast20 <- (abs(cor_blomqvist_mat) > 0.65) & (abs(cor_XI_mat) < 0.45)
cor_contrast_ind20 <- which(cor_contrast20, arr.ind = T)
nrow(cor_contrast_ind20)
## [1] 7
par(mfrow = c(2, 5))
for (i in 1:nrow(cor_contrast_ind20)){
index1 <- cor_contrast_ind20[i, 1]; index2 <- cor_contrast_ind20[i, 2]
plot(gen_dat[,index1], gen_dat[,index2], col = gen_label, asp = T,
pch = 16, xlab = paste0(colnames(gen_dat)[index1], ", (", index1, ")"),
ylab = paste0(colnames(gen_dat)[index2], ", (", index2, ")"),
main = paste(paste0("Beta of ", round(cor_blomqvist_mat[index1, index2], 3)),
"\n",
paste0("XI of ", round(cor_XI_mat[index1, index2], 3))))
}
meaningful_index <- rbind(cor_contrast_ind1, cor_contrast_ind2, cor_contrast_ind3,
cor_contrast_ind4, cor_contrast_ind5, cor_contrast_ind6,
cor_contrast_ind7, cor_contrast_ind8, cor_contrast_ind9,
cor_contrast_ind10, cor_contrast_ind11, cor_contrast_ind12,
cor_contrast_ind13, cor_contrast_ind14, cor_contrast_ind15,
cor_contrast_ind16, cor_contrast_ind17, cor_contrast_ind18,
cor_contrast_ind19, cor_contrast_ind20)
# c(3,4,6,8,10)
full_dat2 <- full_dat[, c(1,2,5,7,9,11)]
save(full_dat2,
file = "full_gen_dat2.RData")
load("full_gen_dat2.RData")